<template>
	<view class="contents" :style="'height:'+screenHeight+'px'">


		<!-- <view class="headers">
			<u-search @clickIcon="searchs" @search="searchs" placeholder="科室/医生名称" v-model="keyword"
				:showAction="false">
			</u-search>
		</view> -->

		<view class="listconent">
			<view class="mains" v-for="(item,index) in Subscribe" :key="index">
				<view :class="index==indexshow?'left width color1':'left gary'" @click="isShow(index)">
					<span class="ftypespan">{{item.TJName}}</span>
				</view>
			</view>
		</view>
		<view class="right">
			<view class="rightchird" v-for="(citem,indexs) in DataList" :key="indexs">
				<view @click="Scheduling(citem.TJCategoryId)" style="padding: 0 50rpx;">
					<span class="">{{citem.TJName}}</span>
					<span style="float: right;"><u-icon size="22" name="arrow-right"></u-icon></span>
				</view>
			</view>

		</view>

	</view>
</template>

<script>
	import {
		mapState,
		mapGetters
	} from 'vuex';
	export default {
		data() {
			return {
				TJChildId: '',
				TJNName: '',
				Subscribe: [],
				scrollTop: 0,

				screenHeight: getApp().globalData.screenHeight - 44,
				showtext: false,
				indexshow: 0,
				index: 0,
				Departmen: [],
				keyword: '',
				DataList: [],
			}
		},

		computed: {
			...mapState(['userInfo']),
			...mapGetters(['hasLogin', 'getUserInfo']),
		},

		onLoad(e) {

			this.TJChildId = e.TJChildId
			this.TJNName = e.TJName
			///////////////////////////////代写///////////////////////////////
			console.log(e)
			console.log(66666666666666666666)
		},
		// onBackPress(event) {
		// 	uni.switchTab({
		// 		url: '/pages/index/index'
		// 	});
		// 	return true;
		// },
		onShow() {
			if (this.hasLogin) {
				uni.showLoading({
					title: '加载中'
				})
				this.$store.dispatch('getUserInfo');
				this.getlist()
			} else {
				uni.hideLoading();
				uni.showModal({
					title: '提示',
					content: '登录后才可以操作',
					confirmText: '去登录',
					showCancel: false,
					success: function(res) {
						uni.reLaunch({
							url: '/pages/auth/login'
						})
					}
				});
				return;
			}

		},
		methods: {

			getlist() {
				console.log("查询")
				this.$request('TJCategory', 'GetTJCategory', {

				}).then(res => {
					console.log(res)
					if (res.code == 1) {


						this.indexshow = 0



						this.Subscribe = res.data
						this.DataList = this.Subscribe[0].list

						uni.hideLoading();
					} else {
						uni.hideLoading();
						console.log("获取失败")
					}


				})
			},




			Scheduling(TJCategoryId) {
				console.log(TJCategoryId)
				uni.navigateTo({
					url: `/pages/MedicalExamination/Subscribe/SetMeal/SetMeal?TJCategoryId=${TJCategoryId}&TJChildId=${this.TJChildId}&TJNName=${this.TJNName}`,
					fail(error) {
						console.log(error)
					}
				})
			},
			isShow(index) {
				this.indexshow = index
				this.DataList = this.Subscribe.data[index].list

				console.log(" 111111111111111" + DataList)
				// console.log(this.DepartList)
			},
			addDepartmen() {
				this.$request('Company', 'ComAndDptlist').then(res => {
					if (res.code == 1) {
						this.Departmen = res.data
						this.DataList = this.Departmen[0].DataList
						this.indexshow = 0
						uni.hideLoading();
					} else {
						uni.hideLoading();
						console.log("获取失败")
					}

				})

			},
			// searchs() {
			// 	let keywords = this.keyword
			// 	uni.navigateTo({
			// 		url: `/pages/searchs/index?keyword=${keywords}`,
			// 		fail(error) {
			// 			console.log(error)
			// 		}
			// 	})
			// }
		}
	}
</script>

<style>
	@import './Subscribe.css'
</style>